package com.company.netease;

import java.util.*;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[m];
        for (int i = 0; i < m; i++) {
            arr[i] = sc.nextInt();
        }
        String res = getLeastOrder(n,m,arr);
        for (int i = 0; i < res.length() ; i++) {
            if(i == 0){
                System.out.print(res.charAt(i));
            }else{
                System.out.print(" ");
                System.out.print(res.charAt(i));
            }
        }


    }

    private static String getLeastOrder(int n, int m, int[] arr) {
        if(n == 1){
            return String.valueOf(arr[0]);
        }
        // 需要待插入的数字
        String t = "";
        for (int i = 0; i < m; i++) {
           t += String.valueOf(arr[i]);
        }
        Arrays.sort(arr);
        int[] temp = new int[n - m];
        int index1 = 0, index2 = 0;
        int start = 1;
        while (true){
            while (index1 < m && start == arr[index1]){
                start++;
                index1++;
                continue;
            }
            temp[index2++] = start++;
            if(index2 == n - m){
                break;
            }
        }


        for (int i = 0; i < n - m; i++) {
            int insertValue = temp[i];
            String[] strs = new String[m + 2];
            int st = 0;

            for (int j = 0; j <= m + 1; j++) {
                if (j == 0) {
                    strs[st++] = String.valueOf(String.valueOf(insertValue)) + t;
                } else if (j == m + 1) {
                    strs[st++] = t + String.valueOf(insertValue);
                } else {
                    strs[st++] = t.substring(0, j) + String.valueOf(insertValue) + t.substring(j);
                }
            }

            Arrays.sort(strs, new Comparator<String>() {
                        @Override
                        public int compare(String o1, String o2) {
                            for (int i = 0; i < o1.length(); i++) {
                                if (o1.charAt(i) < o2.charAt(i)) {
                                    return 1;
                                } else if (o1.charAt(i) > o2.charAt(i)) {
                                    return -1;
                                }
                            }
                            return 0;
                        }
                    }
            );

            t = strs[ strs.length - 1];
        }

        return t;

    }
}
